home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
xsw
/
sepwin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-09
|
80KB
|
3,431 lines
/*
* @(#) sepwin.c 9.2 93/09/15 SCOINC
*/
/***************************************************************************
*
* Copyright (c) 1990-1993 The Santa Cruz Operation, Inc.
*
* All rights reserved. No part of this program or publication may be
* reproduced, transmitted, transcribed, stored in a retrieval system,
* or translated into any language or computer language, in any form or
* by any means, electronic, mechanical, magnetic, optical, chemical,
* biological, or otherwise, without the prior written permission of:
*
* The Santa Cruz Operation , Inc. (408) 425-7222
* 400 Encinal St., Santa Cruz, California 95060 USA
*
**************************************************************************/
/*
* Modification History
*
* S001, 15-Sep-93, rickra
* Added disk space window....
* Some little bug fixes...
*
* S000, 27-May-93, rickra
* Initial check in....
*
*/
/*+-------------------------------------------------------------------------
sepwin.c - Create, Manage, and destroy the individual windows.....
Defined functions:
--------------------------------------------------------------------------*/
#include "include/unixincs.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/StringDefs.h>
#include <Xm/Protocols.h>
#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/DrawingA.h>
#include <Xm/PanedW.h>
#include <Xm/ToggleB.h>
#include <Xm/Form.h>
#include <Xm/CascadeB.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/Label.h>
#include "include/buttons.h"
#include "include/resources.h"
#include "include/scales.h"
#include "include/xsw.h"
#include "include/sepwin.h"
#include "include/menus.h"
char widget_title[128];
char widget_icon_name[128];
char *dupstr;
Widget temprc;
extern MyResources res;
/*
* scrolled_ps (scrollbar, scrolled_ps_callback, cbs)
*
* This procedure is called when a scrolled window is scrolled horizontally...
*
*/
void
scrolled_ps (scrollbar, scrolled_ps_callback, cbs)
Widget scrollbar;
struct scrolled_ps_callback_struct *scrolled_ps_callback;
XmScrollBarCallbackStruct *cbs;
{
int value;
int i, j;
int scroll_bar_max;
int t1, t2, t3, t4, t5, t6;
Arg args[32];
int argcount;
/*
fprintf (stdout, " IN scrolled_ps\n");
*/
argcount = 0;
XtSetArg (args[argcount], XmNmaximum, &scroll_bar_max);
argcount++;
XtGetValues (
scrolled_ps_callback ->
server_pointer ->
SEPERATE_WINDOWS_LIST[scrolled_ps_callback ->
button_number].hsb, args, argcount);
/*
fprintf (stdout, " got values\n");
fprintf (stdout, "Scroll_bar max = %d\n", scroll_bar_max);
fprintf (stdout, "Xtnumber= %d\n", scrolled_ps_callback -> number_of_buttons);
*/
for (i = 0; i < scrolled_ps_callback -> number_of_buttons; i++)
{
if (scrolled_ps_callback -> ps_menu[i].type == SORT_BUTTON)
{
/*
* This needs to be changed so that BUTTON_ps_cpu and BUTTON_ps_io use the
* same logic.......
*
* BUTTON_ps_cpu BUTTON_ps_io need to use current_view......etc....
*/
{
if (cbs -> reason != XmCR_DRAG)
{
argcount = 0;
XtSetArg (args[argcount], XmNmarginBottom, 0);
argcount++;
XtSetArg (args[argcount], XmNmarginTop, 0);
argcount++;
XtSetArg (args[argcount], XmNleftAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNleftOffset,
(4 + (scrolled_ps_callback -> ps_menu[i].offset * FWIDTH) - cbs -> value));
argcount++;
XtSetValues (
scrolled_ps_callback -> server_pointer -> SEPERATE_WINDOWS_LIST[scrolled_ps_callback -> button_number].toggle_widget[i],
args, argcount);
if (cbs -> value < ((scrolled_ps_callback -> ps_menu[i].offset * FWIDTH) + (strlen (scrolled_ps_callback -> ps_menu[i].name) * FWIDTH)))
{
if (scrolled_ps_callback -> button_number == BUTTON_ps_mem)
{
if ((scrolled_ps_callback ->
server_pointer -> ps_mem_screen_mode - 1) ==
scrolled_ps_callback ->
ps_menu[i].screen_number)
XtManageChild (
scrolled_ps_callback -> server_pointer -> SEPERATE_WINDOWS_LIST[scrolled_ps_callback -> button_number].toggle_widget[i]);
}
else if (scrolled_ps_callback -> button_number == BUTTON_disk_space)
{
if ((scrolled_ps_callback ->
server_pointer -> disk_space_screen_mode - 1) ==
scrolled_ps_callback ->
ps_menu[i].screen_number)
XtManageChild (
scrolled_ps_callback -> server_pointer -> SEPERATE_WINDOWS_LIST[scrolled_ps_callback -> button_number].toggle_widget[i]);
}
else
XtManageChild (
scrolled_ps_callback -> server_pointer -> SEPERATE_WINDOWS_LIST[scrolled_ps_callback -> button_number].toggle_widget[i]);
}
}
else
{
XtUnmanageChild (
scrolled_ps_callback ->
server_pointer ->
SEPERATE_WINDOWS_LIST[scrolled_ps_callback ->
button_number].toggle_widget[i]);
}
}
}
}
}
void
adjust_window_for_new_screen (SP,
button_num,
new_menulist,
new_menulist_number,
ps_screen,
new_screen_mode)
struct NetworkXswStruct *SP;
int button_num;
ps_menu_struct *new_menulist;
int new_menulist_number;
multi_screen_window_struct *ps_screen;
int new_screen_mode;
{
XmString default_title;
Arg args[32];
int argcount;
int i;
/*
fprintf (stdout, "In adjust_window_for_new_screen\n");
*/
/*
* Set new title....
*/
default_title =
XmStringCreateSimple (ps_screen[new_screen_mode].default_title);
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, default_title);
argcount++;
XtSetValues (SP -> SEPERATE_WINDOWS_LIST[button_num].title_label,
args,
argcount);
/*
* Unmanage all current widgets except the pulldown menu.....
*/
for (i = 0; i < new_menulist_number; i++)
{
if (SP -> SEPERATE_WINDOWS_LIST[button_num].current_screen_mode ==
new_menulist[i].screen_number)
{
XtUnmanageChild (SP -> SEPERATE_WINDOWS_LIST[button_num].toggle_widget[i]);
}
}
for (i = 0; i < new_menulist_number; i++)
{
if (new_screen_mode == new_menulist[i].screen_number)
{
XtManageChild (SP -> SEPERATE_WINDOWS_LIST[button_num].toggle_widget[i]);
}
}
SP -> SEPERATE_WINDOWS_LIST[button_num].current_screen_mode = new_screen_mode;
XmStringFree (default_title);
}
void
ps_button_callback (my_widget, ps_button_struct, cbs)
Widget my_widget;
struct ps_button_callback_struct *ps_button_struct;
XmToggleButtonCallbackStruct *cbs;
{
struct NetworkXswStruct *SP = ps_button_struct -> server_pointer;
#if 0
XmString cum_string, cur_string;
XmString acsending_string, descending_string;
XmString percent_string, ticks_string, minutes_string, count_string;
#endif
XmString label_string;
XmString default_title;
Arg args[32];
int argcount;
struct NetworkXswStruct *temp_server;
int j = 0;
int i = 0;
/*
fprintf (stdout, "In ps_button_callback....\n");
*/
#if 0
cum_string = XmStringCreateSimple ("CUM");
cur_string = XmStringCreateSimple ("CUR");
acsending_string = XmStringCreateSimple ("A");
descending_string = XmStringCreateSimple ("D");
percent_string = XmStringCreateSimple ("%");
ticks_string = XmStringCreateSimple ("T");
minutes_string = XmStringCreateSimple ("M");
count_string = XmStringCreateSimple ("C");
#endif
/*
* Check to see if we are changeing the current ("VIEW") screen.... or else
* it must be a toggle widget......
*/
#if 0
if (ps_button_struct -> ps_menu_index == -1)
{
/*
fprintf (stdout, "Chaning view....\n");
*/
/*
* Turn the button "ON" .....
*/
argcount = 0;
XtSetArg (args[argcount], XmNbackground,
colorAuxButtonOnBackground.pixel);
argcount++;
XtSetArg (args[argcount], XmNforeground,
colorAuxButtonOnForeground.pixel);
argcount++;
XtSetValues (my_widget, args, argcount);
/*
* Turn "OFF" the old button.....
*/
argcount = 0;
XtSetArg (args[argcount], XmNbackground,
colorAuxButtonOffBackground.pixel);
argcount++;
XtSetArg (args[argcount], XmNforeground,
colorAuxButtonOffForeground.pixel);
argcount++;
/*
* Currently, PS MEM has 4 screens.......
*/
if (ps_button_struct -> button_num == BUTTON_ps_mem)
{
XtSetValues (
SP -> SEPERATE_WINDOWS_LIST[ps_button_struct ->
button_num].screen_widget_list[SP ->
ps_mem_screen_mode - 1],
args, argcount);
/*
* If we are currently screen 1, then change
*/
adjust_window_for_new_screen (
SP,
ps_button_struct -> button_num,
ps_mem_toggle_button_data,
XtNumber (ps_mem_toggle_button_data),
ps_button_struct -> ps_screen,
ps_button_struct -> sort_mode);
if (ps_button_struct -> sort_mode == 1)
{
SP -> ps_mem_screen_mode = 2;
}
else if (ps_button_struct -> sort_mode == 2)
{
SP -> ps_mem_screen_mode = 3;
}
else if (ps_button_struct -> sort_mode == 3)
{
SP -> ps_mem_screen_mode = 4;
}
else if (ps_button_struct -> sort_mode == 0)
{
SP -> ps_mem_screen_mode = 1;
}
else
{
}
}
else if (ps_button_struct -> button_num == BUTTON_disk_space)
{
XtSetValues (SP -> SEPERATE_WINDOWS_LIST[ps_button_struct ->
button_num].screen_widget_list[SP ->
disk_space_screen_mode - 1],
args, argcount);
/*
* If we are currently screen 1, then change
*/
adjust_window_for_new_screen (
SP,
ps_button_struct -> button_num,
disk_space_toggle_button_data,
XtNumber (disk_space_toggle_button_data),
ps_button_struct -> ps_screen,
ps_button_struct -> sort_mode);
if (ps_button_struct -> sort_mode == 1)
{
SP -> disk_space_screen_mode = 2;
}
else if (ps_button_struct -> sort_mode == 2)
{
SP -> disk_space_screen_mode = 3;
}
else if (ps_button_struct -> sort_mode == 0)
{
SP -> disk_space_screen_mode = 1;
}
else
{
}
}
}
else
/*
* Check to see if we are changeing the current ("OPTION") ....
*/
if (ps_button_struct -> ps_menu_index == -2)
{
/*
fprintf (stdout, "Changing option the old way??....\n");
*/
}
/*
* If it is a SORT_BUTTON, then set the Old toggle button as inactive...
* and set the New toggle button as active...
*/
#endif
if (ps_button_struct -> ps_menu[ps_button_struct -> ps_menu_index].type ==
SORT_BUTTON)
{
/*
fprintf (stdout, "Sort button\n ");
*/
argcount = 0;
XtSetArg (args[argcount], XmNbackground,
colorAuxButtonOffBackground.pixel);
argcount++;
XtSetArg (args[argcount], XmNforeground,
colorAuxButtonOffForeground.pixel);
argcount++;
if (ps_button_struct -> button_num == BUTTON_ps_cpu)
{
XtSetValues (SP -> SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].toggle_widget[SP -> ps_sort_mode],
args,
argcount);
SP -> ps_sort_mode =
ps_button_struct -> sort_mode;
}
else if (ps_button_struct -> button_num == BUTTON_ps_mem)
{
/*
* Need to set the current toggle widget indice......TURN OFF OLD BUTTON
*/
XtSetValues (
SP -> SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].view_current_sort_widget[SP -> ps_mem_screen_mode - 1],
args,
argcount);
SP -> ps_mem_sort_mode[SP -> ps_mem_screen_mode - 1] =
ps_button_struct -> sort_mode;
}
else if (ps_button_struct -> button_num == BUTTON_ps_io)
{
XtSetValues (SP -> SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].toggle_widget[SP -> ps_io_sort_mode],
args,
argcount);
SP -> ps_io_sort_mode =
ps_button_struct -> sort_mode;
}
else if (ps_button_struct -> button_num == BUTTON_disk_space)
{
XtSetValues (SP -> SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].view_current_sort_widget[SP -> disk_space_screen_mode - 1],
args,
argcount);
SP -> disk_space_sort_mode[SP -> disk_space_screen_mode - 1] =
ps_button_struct -> sort_mode;
}
/*
* Turn on button pushed.......
*/
argcount = 0;
XtSetArg (args[argcount], XmNbackground,
colorAuxButtonOnBackground.pixel);
argcount++;
XtSetArg (args[argcount], XmNforeground,
colorAuxButtonOnForeground.pixel);
argcount++;
XtSetValues (my_widget, args, argcount);
/*
* If this is a VIEW window, then need to keep track of the active sort
* for each view....
*
*/
if (ps_button_struct -> button_num == BUTTON_ps_mem)
SP -> SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].view_current_sort_widget[SP -> ps_mem_screen_mode - 1] = my_widget;
else
SP -> SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].view_current_sort_widget[SP -> disk_space_screen_mode - 1] = my_widget;
}
#if 0
else if (ps_button_struct -> ps_menu[ps_button_struct -> ps_menu_index].type
== CUM_CUR_BUTTON)
{
/*
fprintf (stdout, "cum/cur button\n ");
*/
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, &label_string);
argcount++;
XtGetValues (my_widget, args, argcount);
/*
fprintf (stdout, "about to string compare\n ");
*/
if (XmStringCompare (cum_string, label_string) == False)
{
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, cum_string);
argcount++;
XtSetValues (my_widget, args, argcount);
if (ps_button_struct -> button_num == BUTTON_ps_cpu)
{
SP -> ps_display_mode = 13;
if (SP -> ps_cpu_time_mode == 2)
{
SP -> ps_cpu_time_mode = 0;
for (j = 0; j < XtNumber (ps_toggle_button_data); j++)
if (ps_button_struct ->
ps_menu[j].type == PERCENT_OTHER_BUTTON)
{
argcount = 0;
XtSetArg (args[argcount], XmNlabelString,
minutes_string);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].toggle_widget[j],
args, argcount);
}
}
}
else if (ps_button_struct -> button_num == BUTTON_ps_io)
{
SP -> ps_io_display_mode = 9;
}
}
else
{
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, cur_string);
argcount++;
XtSetValues (my_widget, args, argcount);
if (ps_button_struct -> button_num == BUTTON_ps_cpu)
{
SP -> ps_display_mode = 12;
if (SP -> ps_cpu_time_mode == 0)
{
if (SP -> ps_cpu_time_mode == 0)
{
SP -> ps_cpu_time_mode = 2;
for (j = 0; j < XtNumber (ps_toggle_button_data); j++)
if (ps_button_struct -> ps_menu[j].type == PERCENT_OTHER_BUTTON)
{
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, ticks_string);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].toggle_widget[j],
args, argcount);
}
}
}
}
else if (ps_button_struct -> button_num == BUTTON_ps_io)
{
SP -> ps_io_display_mode = 8;
}
}
}
else if (ps_button_struct -> ps_menu[ps_button_struct -> ps_menu_index].type
== ASCEND_DESCEND_BUTTON)
{
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, &label_string);
argcount++;
XtGetValues (my_widget, args, argcount);
if (XmStringCompare (acsending_string, label_string) == False)
{
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, acsending_string);
argcount++;
XtSetValues (my_widget, args, argcount);
if (ps_button_struct -> button_num == BUTTON_ps_cpu)
SP -> ps_cpu_sort_order = 0;
else if (ps_button_struct -> button_num == BUTTON_ps_io)
SP -> ps_io_sort_order = 0;
/*
else if (ps_button_struct -> button_num == BUTTON_ps_mem)
SP -> ps_mem_sort_order[SP -> ps_mem_screen_mode - 1] = 0;
else if (ps_button_struct -> button_num == BUTTON_disk_space)
SP -> disk_space_sort_order[SP -> disk_space_screen_mode - 1] = 0;
*/
}
else
{
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, descending_string);
argcount++;
XtSetValues (my_widget, args, argcount);
if (ps_button_struct -> button_num == BUTTON_ps_cpu)
SP -> ps_cpu_sort_order = 1;
else if (ps_button_struct -> button_num == BUTTON_ps_io)
SP -> ps_io_sort_order = 1;
/*
else if (ps_button_struct -> button_num == BUTTON_ps_mem)
SP -> ps_mem_sort_order[SP -> ps_mem_screen_mode - 1] = 1;
else if (ps_button_struct -> button_num == BUTTON_disk_space)
SP -> disk_space_sort_order[SP -> disk_space_screen_mode - 1] = 1;
*/
}
}
else if (ps_button_struct -> ps_menu[ps_button_struct -> ps_menu_index].type
== PERCENT_OTHER_BUTTON)
{
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, &label_string);
argcount++;
XtGetValues (my_widget, args, argcount);
/*
* Percent string ......
*/
if (XmStringCompare (percent_string, label_string) == True)
{
if (ps_button_struct -> button_num == BUTTON_ps_cpu)
{
if (SP -> ps_display_mode == 13)
{
SP -> ps_cpu_time_mode = 0;
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, minutes_string);
argcount++;
XtSetValues (my_widget, args, argcount);
}
else
{
SP -> ps_cpu_time_mode = 2;
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, ticks_string);
argcount++;
XtSetValues (my_widget, args, argcount);
}
}
else if (ps_button_struct -> button_num == BUTTON_ps_io)
{
SP -> ps_io_time_mode = 0;
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, count_string);
argcount++;
XtSetValues (my_widget, args, argcount);
}
}
/*
* Ticks string ......
*/
else if (XmStringCompare (ticks_string, label_string) == True)
{
if (ps_button_struct -> button_num == BUTTON_ps_cpu)
{
if (SP -> ps_display_mode == 13)
{
}
else
{
SP -> ps_cpu_time_mode = 1;
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, percent_string);
argcount++;
XtSetValues (my_widget, args, argcount);
}
}
else if (ps_button_struct -> button_num == BUTTON_ps_io)
{
}
}
/*
* Minutes string ......
*/
else if (XmStringCompare (minutes_string, label_string) == True)
{
if (ps_button_struct -> button_num == BUTTON_ps_cpu)
{
if (SP -> ps_display_mode == 13)
{
SP -> ps_cpu_time_mode = 1;
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, percent_string);
argcount++;
XtSetValues (my_widget, args, argcount);
}
else
{
}
}
else if (ps_button_struct -> button_num == BUTTON_ps_io)
{
}
}
else if (XmStringCompare (count_string, label_string) == True)
{
if (ps_button_struct -> button_num == BUTTON_ps_io)
{
SP -> ps_io_time_mode = 1;
argcount = 0;
XtSetArg (args[argcount], XmNlabelString, percent_string);
argcount++;
XtSetValues (my_widget, args, argcount);
}
}
}
#endif
temp_server = current_server;;
current_server = SP;
switch ( ps_button_struct -> button_num ) {
case BUTTON_ps_cpu:
SP -> ps_button_change = 1;
update_ps_cpu (SP);
break;
case BUTTON_ps_mem:
SP -> ps_mem_button_change = 1;
update_ps_mem (SP);
break;
case BUTTON_ps_io:
SP -> ps_io_button_change = 1;
update_ps_io(SP);
break;
case BUTTON_disk_space:
update_disk_space(SP);
break;
}
current_server = temp_server;
XCopyArea (
SP ->
SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].display,
SP ->
SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].pixmap,
SP ->
SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].window,
SP ->
SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].gc,
0,
0,
SP ->
SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].draw_width,
SP ->
SEPERATE_WINDOWS_LIST[ps_button_struct -> button_num].draw_height,
0,
0);
#if 0
XmStringFree (cum_string);
XmStringFree (cur_string);
XmStringFree (acsending_string);
XmStringFree (descending_string);
XmStringFree (percent_string);
XmStringFree (ticks_string);
XmStringFree (minutes_string);
#endif
}
void
option_callback (my_widget, window_button_struct, cbs)
Widget my_widget;
struct window_button_callback_struct *window_button_struct;
XmToggleButtonCallbackStruct *cbs;
{
Arg args[32];
int argcount;
struct NetworkXswStruct *temp_server;
struct NetworkXswStruct *SP = window_button_struct -> server_pointer;
/*
fprintf (stdout, "In option_callback ...\n");
fprintf (stdout, "dynamic window_indow = %d...\n",
window_button_struct -> dynamic_window_index);
*/
if (window_button_struct -> ps_menu_index == -2)
{
/*
fprintf (stdout, "Chaning view....\n");
*/
if (window_button_struct -> button_num == BUTTON_disk_space)
{
/*
fprintf (stdout, "Turning off old button....\n");
*/
/*
* If our view has not changed, then we should re-set the toggle button state
* to true, and the just return.....
*/
if ((window_button_struct -> sort_mode + 1) == SP ->
disk_space_screen_mode)
{
XmToggleButtonSetState (my_widget, True, False);
return;
}
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
SP -> disk_space_screen_mode - 1],
False, False);
/*
* If we are currently screen 1, then change
*/
adjust_window_for_new_screen (
SP,
window_button_struct -> button_num,
disk_space_toggle_button_data,
XtNumber (disk_space_toggle_button_data),
window_button_struct -> ps_screen,
window_button_struct -> sort_mode);
switch (window_button_struct -> sort_mode)
{
case 0:
SP -> disk_space_screen_mode = 1;
break;
case 1:
SP -> disk_space_screen_mode = 2;
break;
case 2:
SP -> disk_space_screen_mode = 3;
break;
}
}
else if (window_button_struct -> button_num == BUTTON_ps_mem)
{
/*
fprintf (stdout, "Changing view for ps_mem....\n");
*/
/*
* If our view has not changed, then we should re-set the toggle button state
* to true, and the just return.....
*/
/*
fprintf (stdout, "Changing view for ps_mem....%d, %d\n",
window_button_struct -> sort_mode + 1,
SP -> ps_mem_screen_mode);
*/
if ((window_button_struct -> sort_mode + 1) == SP ->
ps_mem_screen_mode)
{
XmToggleButtonSetState (my_widget, True, False);
return;
}
/*
fprintf (stdout, "Turning off old button ps_mem....%d\n",
SP -> ps_mem_screen_mode - 1);
*/
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
SP -> ps_mem_screen_mode - 1],
False, False);
/*
* If we are currently screen 1, then change
*/
/*
fprintf (stdout, "About to adjust the ps_mem....\n");
*/
adjust_window_for_new_screen (
SP,
window_button_struct -> button_num,
ps_mem_toggle_button_data,
XtNumber (ps_mem_toggle_button_data),
window_button_struct -> ps_screen,
window_button_struct -> sort_mode);
/*
fprintf (stdout, "Done adjust the ps_mem....\n");
*/
if (window_button_struct -> sort_mode == 1)
{
SP -> ps_mem_screen_mode = 2;
}
else if (window_button_struct -> sort_mode == 2)
{
SP -> ps_mem_screen_mode = 3;
}
else if (window_button_struct -> sort_mode == 3)
{
SP -> ps_mem_screen_mode = 4;
}
else if (window_button_struct -> sort_mode == 0)
{
SP -> ps_mem_screen_mode = 1;
}
}
}
if (window_button_struct -> type == ASCEND_DESCEND_BUTTON)
{
/*
fprintf (stdout, "GOT ascend/descend....%d\n",
window_button_struct -> sort_mode);
*/
switch (window_button_struct -> sort_mode)
{
case 0:
/*
* Need to determine whether it is going of or on....
*/
if (XmToggleButtonGetState (my_widget))
{
/*
fprintf (stdout, "Chaning ascend/descend....\n");
*/
switch (window_button_struct -> button_num)
{
case BUTTON_disk_space:
SP -> disk_space_sort_order = 1;
break;
case BUTTON_ps_mem:
SP -> ps_mem_sort_order = 1;
break;
case BUTTON_ps_io:
SP -> ps_io_sort_order = 1;
break;
case BUTTON_ps_cpu:
SP -> ps_cpu_sort_order = 1;
break;
}
/*
if (window_button_struct -> button_num == BUTTON_disk_space)
SP -> disk_space_sort_order = 1;
else if (window_button_struct -> button_num == BUTTON_ps_mem)
SP -> ps_mem_sort_order = 1;
*/
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct -> dynamic_window_index + 1],
False, False);
}
else
{
/*
* We were on, and we should stay ON....
*/
XmToggleButtonSetState (my_widget, True, False);
return;
}
break;
case 1:
if (XmToggleButtonGetState (my_widget))
{
switch (window_button_struct -> button_num)
{
case BUTTON_disk_space:
SP -> disk_space_sort_order = 0;
break;
case BUTTON_ps_mem:
SP -> ps_mem_sort_order = 0;
break;
case BUTTON_ps_io:
SP -> ps_io_sort_order = 0;
break;
case BUTTON_ps_cpu:
SP -> ps_cpu_sort_order = 0;
break;
}
/*
if (window_button_struct -> button_num == BUTTON_disk_space)
SP -> disk_space_sort_order = 0;
else if (window_button_struct -> button_num == BUTTON_ps_mem)
SP -> ps_mem_sort_order = 0;
*/
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct -> dynamic_window_index - 1],
False, False);
}
else
{
/*
* We were on, and we should stay ON....
*/
XmToggleButtonSetState (my_widget, True, False);
return;
}
break;
}
}
if (window_button_struct -> type == CUM_CUR_BUTTON)
{
/*
fprintf (stdout, "GOT CUM_CUR_BUTTON ....%d\n",
window_button_struct -> sort_mode);
*/
switch (window_button_struct -> sort_mode)
{
case 0:
/*
* Need to determine whether it is going of or on....
*/
if (XmToggleButtonGetState (my_widget))
{
/*
fprintf (stdout, "Changing to cummulative....\n");
*/
switch (window_button_struct -> button_num)
{
case BUTTON_ps_io:
SP -> ps_io_display_mode = 8;
break;
case BUTTON_ps_cpu:
SP -> ps_display_mode = 12;
/*
* Stipple out minutes , and unstiplle ticks....
*/
argcount = 0;
XtSetArg (args[argcount], XmNsensitive, False);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct ->
dynamic_window_index + 3], args, argcount);
argcount = 0;
XtSetArg (args[argcount], XmNsensitive, True);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct ->
dynamic_window_index + 4], args, argcount);
/*
* If we are currently showing minutes , then we need to
* change to ticks ....
*/
if (SP -> ps_cpu_time_mode == 0)
{
SP -> ps_cpu_time_mode = 2;
/*
* Turn off minutes....
*/
argcount = 0;
XtSetArg (args[argcount], XmNset, False);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct ->
dynamic_window_index + 3], args, argcount);
/*
* Turn on ticks....
*/
argcount = 0;
XtSetArg (args[argcount], XmNset, True);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct ->
dynamic_window_index + 4], args, argcount);
}
break;
}
/*
* Now turn off CUMMULATIVE.....
*/
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct -> dynamic_window_index + 1],
False, False);
}
else
{
/*
* We were on, and we should stay ON....
*/
XmToggleButtonSetState (my_widget, True, False);
return;
}
break;
case 1:
if (XmToggleButtonGetState (my_widget))
{
/*
fprintf (stdout, "Changing to current....\n");
*/
switch (window_button_struct -> button_num)
{
case BUTTON_ps_io:
SP -> ps_io_display_mode = 9;
break;
case BUTTON_ps_cpu:
SP -> ps_display_mode = 13;
/*
* Stipple out ticks, and unstiplle minutes....
*/
argcount = 0;
XtSetArg (args[argcount], XmNsensitive, False);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct ->
dynamic_window_index + 3], args, argcount);
argcount = 0;
XtSetArg (args[argcount], XmNsensitive, True);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct ->
dynamic_window_index + 2], args, argcount);
/*
* If we are currently showing ticks, then we need to
* change to Minutes....
*/
if (SP -> ps_cpu_time_mode == 2)
{
SP -> ps_cpu_time_mode = 0;
/*
* Turn off ticks....
*/
argcount = 0;
XtSetArg (args[argcount], XmNset, False);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct ->
dynamic_window_index + 3], args, argcount);
/*
* Turn on minutes ....
*/
argcount = 0;
XtSetArg (args[argcount], XmNset, True);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct ->
dynamic_window_index + 2], args, argcount);
}
break;
}
/*
* Now turn off CURRENT.....
*/
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct -> dynamic_window_index - 1],
False, False);
}
else
{
/*
* We were on, and we should stay ON....
*/
XmToggleButtonSetState (my_widget, True, False);
return;
}
break;
}
}
else if (window_button_struct -> type == PERCENT_OTHER_BUTTON)
{
/*
fprintf (stdout, "GOT percent/count ....%d\n",
window_button_struct -> sort_mode);
*/
switch (window_button_struct -> sort_mode)
{
case 0:
/*
fprintf (stdout, "going to percent ....%d\n",
window_button_struct -> sort_mode);
*/
if (XmToggleButtonGetState (my_widget))
{
switch (window_button_struct -> button_num)
{
case BUTTON_ps_io:
SP -> ps_io_time_mode = 1;
break;
case BUTTON_ps_cpu:
/*
fprintf (stdout, "Current time mode = %d\n",
SP -> ps_cpu_time_mode);
*/
SP -> ps_cpu_time_mode = 1;
break;
}
/*
* Turn of minutes and ticks....
*/
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct -> dynamic_window_index + 1],
False, False);
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct -> dynamic_window_index + 2],
False, False);
}
else
{
/*
* We were on, and we should stay ON....
*/
XmToggleButtonSetState (my_widget, True, False);
return;
}
break;
case 1:
if (XmToggleButtonGetState (my_widget))
{
/*
fprintf (stdout, "Chaning to minutes....\n");
*/
switch (window_button_struct -> button_num)
{
case BUTTON_ps_io:
SP -> ps_io_time_mode = 0;
break;
case BUTTON_ps_cpu:
/*
fprintf (stdout, "Current time mode = %d\n",
SP -> ps_cpu_time_mode);
*/
if (SP -> ps_display_mode == 13)
{
SP -> ps_cpu_time_mode = 0;
}
else
{
/*
fprintf (stdout, "Minutes should be stippled out!\n");
*/
}
break;
}
/*
* Turn off ticks....
*/
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct -> dynamic_window_index - 1],
False, False);
}
else
{
/*
* We were on, and we should stay ON....
*/
XmToggleButtonSetState (my_widget, True, False);
return;
}
break;
case 2:
if (XmToggleButtonGetState (my_widget))
{
/*
fprintf (stdout, "Chaning to ticks....\n");
*/
switch (window_button_struct -> button_num)
{
case BUTTON_ps_io:
SP -> ps_io_time_mode = 0;
break;
case BUTTON_ps_cpu:
/*
fprintf (stdout, "Current time mode = %d\n",
SP -> ps_cpu_time_mode);
*/
if (SP -> ps_display_mode == 13)
{
/*
fprintf (stdout, "Ticks should be stippled out\n");
*/
}
else
{
SP -> ps_cpu_time_mode = 2;
}
break;
}
/*
* Turn of percent and minutes....
*/
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct -> dynamic_window_index - 2],
False, False);
XmToggleButtonSetState (
SP -> SEPERATE_WINDOWS_LIST[window_button_struct ->
button_num].screen_widget_list[
window_button_struct -> dynamic_window_index - 1],
False, False);
}
else
{
/*
* We were on, and we should stay ON....
*/
XmToggleButtonSetState (my_widget, True, False);
return;
}
break;
}
}
else if (window_button_struct -> type == SHOW_NFS_BUTTON)
{
/*
fprintf (stdout, "SHOW_NFS_BUTTON was pressed\n");
*/
if (XmToggleButtonGetState (my_widget))
{
if (window_button_struct -> button_num == BUTTON_disk_space)
{
SP -> show_nfs = 1;
}
}
else
{
if (window_button_struct -> button_num == BUTTON_disk_space)
{
SP -> show_nfs = 0;
}
}
}
else if (window_button_struct -> type == SHOW_TOTAL_BUTTON)
{
/*
fprintf (stdout, "SHOW_TOTAL_BUTTON was pressed\n");
*/
if (XmToggleButtonGetState (my_widget))
{
if (window_button_struct -> button_num == BUTTON_disk_space)
{
SP -> show_disk_totals = 1;
}
}
else
{
if (window_button_struct -> button_num == BUTTON_disk_space)
{
SP -> show_disk_totals = 0;
}
}
}
/*
* If we have gotten this far, then the screen needs to be changed in some
* manner.....
*/
/*
fprintf (stdout, "About to update the WINDOW....\n");
*/
temp_server = current_server;;
current_server = SP;
switch (window_button_struct -> button_num)
{
case BUTTON_disk_space:
update_disk_space (SP);
break;
case BUTTON_ps_mem:
update_ps_mem (SP);
break;
case BUTTON_ps_io:
update_ps_io (SP);
break;
case BUTTON_ps_cpu:
update_ps_cpu (SP);
break;
}
current_server = temp_server;
XCopyArea (
SP ->
SEPERATE_WINDOWS_LIST[window_button_struct -> button_num].display,
SP ->
SEPERATE_WINDOWS_LIST[window_button_struct -> button_num].pixmap,
SP ->
SEPERATE_WINDOWS_LIST[window_button_struct -> button_num].window,
SP ->
SEPERATE_WINDOWS_LIST[window_button_struct -> button_num].gc,
0,
0,
SP ->
SEPERATE_WINDOWS_LIST[window_button_struct -> button_num].draw_width,
SP ->
SEPERATE_WINDOWS_LIST[window_button_struct -> button_num].draw_height,
0,
0);
/*
fprintf (stdout, "Sort mode = %d\n", window_button_struct -> sort_mode);
*/
}
static xs_window_menu_struct View_list_data[] =
{
{"MB SPACE", 'M', option_callback,
0, NULL, 0, NULL, 0, 0, TOGGLE_ON, 1},
{"BLOCKS", 'B', option_callback,
0, NULL, 0, NULL, 1, 1, TOGGLE_OFF, 1},
{"INODES", 'I', option_callback,
0, NULL, 0, NULL, 2, 2, TOGGLE_OFF, 1}
};
static xs_window_menu_struct Sort_list_data[] =
{
{"DESCENDING", 'D', option_callback,
0, NULL, 0, NULL, 3, 0, TOGGLE_ON, 1},
{"ASCENDING", 'A', option_callback,
0, NULL, 0, NULL, 4, 1, TOGGLE_OFF, 1}
};
static xs_window_menu_struct option_menu_data[] =
{
{"VIEW", 'V', NULL, NULL, View_list_data, XtNumber (View_list_data), NULL, -1, 0, TOGGLE_OFF, 0},
{"SORTING ORDER", 'S', NULL, NULL, Sort_list_data, XtNumber (Sort_list_data),
NULL, -1, 0, TOGGLE_OFF, 0},
{"SHOW NFS", 'N', option_callback, NULL, NULL, 0, NULL, 5, 0, TOGGLE_ON, 2},
{"SHOW TOTAL", 'T', option_callback, NULL, NULL, NULL, NULL, 6, 0, TOGGLE_ON, 2}
};
static xs_window_menu_struct option_menu_bar_data[] =
{
{"OPTIONS", 'O', NULL, NULL, option_menu_data,
XtNumber (option_menu_data), NULL, -1, 0, TOGGLE_OFF, 0}
};
/*
* Begin PS_MEM menu bar definitions....
*/
static xs_window_menu_struct ps_mem_view_menu_data[] =
{
{"Core Storage Only: Private & Shared", 'P', option_callback,
0, NULL, 0, NULL, 0, 0, TOGGLE_ON, 1},
{"Core Storage Only", 'C', option_callback,
0, NULL, 0, NULL, 1, 1, TOGGLE_OFF, 1},
{"All Storage", 'A', option_callback,
0, NULL, 0, NULL, 2, 2, TOGGLE_OFF, 1},
{"Secondary Storage Only", 'S', option_callback,
0, NULL, 0, NULL, 3, 3, TOGGLE_OFF, 1}
};
static xs_window_menu_struct ps_mem_sort_menu_data[] =
{
{"DESCENDING", 'D', option_callback,
0, NULL, 0, NULL, 4, 0, TOGGLE_ON, 1},
{"ASCENDING", 'A', option_callback,
0, NULL, 0, NULL, 5, 1, TOGGLE_OFF, 1}
};
static xs_window_menu_struct ps_mem_option_menu_data[] =
{
{"VIEW", 'V', NULL, NULL, ps_mem_view_menu_data,
XtNumber (ps_mem_view_menu_data), NULL, -1, 0, TOGGLE_OFF, 0},
{"SORTING ORDER", 'O', NULL, NULL, ps_mem_sort_menu_data,
XtNumber (ps_mem_sort_menu_data), NULL, -1, 0, TOGGLE_OFF, 0}
};
static xs_window_menu_struct ps_mem_option_menu_bar_data[] =
{
{"OPTIONS", 'O', NULL, NULL, ps_mem_option_menu_data,
XtNumber (ps_mem_option_menu_data), NULL, -1, 0, TOGGLE_OFF, 0}
};
/*
* Begin PS_IO menu bar definitions....
*/
static xs_window_menu_struct ps_io_sort_menu_data[] =
{
{"DESCENDING", 'D', option_callback,
0, NULL, 0, NULL, 0, 0, TOGGLE_ON, 1},
{"ASCENDING", 'A', option_callback,
0, NULL, 0, NULL, 1, 1, TOGGLE_OFF, 1}
};
static xs_window_menu_struct ps_io_mode_menu_data[] =
{
{"CURRENT", 'C', option_callback,
0, NULL, 0, NULL, 2, 0, TOGGLE_ON, 1},
{"CUMMULATIVE", 'M', option_callback,
0, NULL, 0, NULL, 3, 1, TOGGLE_OFF, 1}
};
static xs_window_menu_struct ps_io_display_menu_data[] =
{
{"PERCENT", 'P', option_callback,
0, NULL, 0, NULL, 4, 0, TOGGLE_ON, 1},
{"COUNT", 'C', option_callback,
0, NULL, 0, NULL, 5, 1, TOGGLE_OFF, 1}
};
static xs_window_menu_struct ps_io_option_menu_data[] =
{
{"SORTING ORDER", 'O', NULL, NULL, ps_io_sort_menu_data,
XtNumber (ps_io_sort_menu_data), NULL, -1, 0, TOGGLE_OFF, 0},
{"SORTING MODE", 'M', NULL, NULL, ps_io_mode_menu_data,
XtNumber (ps_io_mode_menu_data), NULL, -1, 0, TOGGLE_OFF, 0}
/*
{"DISPLAY TYPE", 'T', NULL, NULL, ps_io_display_menu_data,
XtNumber (ps_io_display_menu_data), NULL, -1, 0, 0, 0}
*/
/* ^^
THIS MAY NEED TO CHANGE........... ......
*/
};
static xs_window_menu_struct ps_io_option_menu_bar_data[] =
{
{"OPTIONS", 'O', NULL, NULL, ps_io_option_menu_data,
XtNumber (ps_io_option_menu_data), NULL, -1, 0, TOGGLE_OFF, 0}
};
/*
* Begin PS_CPU menu bar definitions....
*/
static xs_window_menu_struct ps_cpu_sort_menu_data[] =
{
{"DESCENDING", 'D', option_callback,
0, NULL, 0, NULL, 0, 0, TOGGLE_ON, 1},
{"ASCENDING", 'A', option_callback,
0, NULL, 0, NULL, 1, 1, TOGGLE_OFF, 1}
};
/*
* If changing the relative positions of CURRENT/CUMMULATIVE to
* PERCENT/MINUTES/TICKS, be sure to update the callbacks knowlege of
* this change......
*/
static xs_window_menu_struct ps_cpu_mode_menu_data[] =
{
{"CURRENT", 'C', option_callback,
0, NULL, 0, NULL, 2, 0, TOGGLE_ON, 1},
{"CUMMULATIVE", 'M', option_callback,
0, NULL, 0, NULL, 3, 1, TOGGLE_OFF, 1}
};
static xs_window_menu_struct ps_cpu_display_menu_data[] =
{
{"PERCENT", 'P', option_callback,
0, NULL, 0, NULL, 4, 0, TOGGLE_ON, 1},
{"MINUTES", 'M', option_callback,
0, NULL, 0, NULL, 5, 1, TOGGLE_OFF | TOGGLE_STIPPLED, 1},
{"TICKS", 'T', option_callback,
0, NULL, 0, NULL, 6, 2, TOGGLE_OFF, 1},
};
static xs_window_menu_struct ps_cpu_option_menu_data[] =
{
{"SORTING ORDER", 'O', NULL, NULL, ps_cpu_sort_menu_data,
XtNumber (ps_cpu_sort_menu_data), NULL, -1, 0, TOGGLE_OFF, 0},
{"SORTING MODE", 'M', NULL, NULL, ps_cpu_mode_menu_data,
XtNumber (ps_cpu_mode_menu_data), NULL, -1, 0, TOGGLE_OFF, 0},
{"DISPLAY TYPE", 'T', NULL, NULL, ps_cpu_display_menu_data,
XtNumber (ps_cpu_display_menu_data), NULL, -1, 0, TOGGLE_OFF, 0}
};
static xs_window_menu_struct ps_cpu_option_menu_bar_data[] =
{
{"OPTIONS", 'O', NULL, NULL, ps_cpu_option_menu_data,
XtNumber (ps_cpu_option_menu_data), NULL, -1, 0, TOGGLE_OFF, 0}
};
int
fill_in_dynamic_window_button_struct (server_pointer,
button,
window_button_struct,
parent_name,
list,
entries,
current_index)
struct NetworkXswStruct *server_pointer;
int button;
struct window_button_callback_struct *window_button_struct;
char *parent_name;
xs_window_menu_struct *list;
int entries;
int current_index;
{
int i = 0;
for (i = 0; i < entries; i++)
{
if (list[i].sub_menu != NULL)
{
current_index =
fill_in_dynamic_window_button_struct (server_pointer,
button,
window_button_struct,
list[i].name,
list[i].sub_menu,
list[i].n_sub_items,
current_index);
}
else
{
if (list[i].dynamic_data_index != -1)
{
/*
* Set up DEFAULT settings...
*/
window_button_struct[current_index].sort_mode = list[i].sort_mode;
window_button_struct[current_index].server_pointer =
server_pointer;
window_button_struct[current_index].button_num = button;
window_button_struct[current_index].dynamic_window_index =
current_index;
window_button_struct[current_index].ps_menu = NULL;
window_button_struct[current_index].ps_menu_index = 0;
window_button_struct[current_index].ps_screen_number = 0;
if (button == BUTTON_disk_space)
window_button_struct[current_index].ps_screen =
disk_space_screens;
else if (button == BUTTON_ps_mem)
window_button_struct[current_index].ps_screen =
ps_mem_screens;
/*
* Begin specific settings....
*/
if (strcmp (parent_name, "VIEW") == 0)
{
/*
fprintf (stdout, "Setting type to VIEW at %d\n ",
current_index);
*/
window_button_struct[current_index].ps_menu_index = -2;
window_button_struct[current_index].ps_screen_number =
list[i].sort_mode;
current_index++;
}
else if (strcmp (parent_name, "SORTING ORDER") == 0)
{
/*
fprintf (stdout, "Setting type to ASCEND_DESCEND_BUTTON at %d\n ",
current_index);
*/
window_button_struct[current_index].type =
ASCEND_DESCEND_BUTTON;
current_index++;
}
else if (strcmp (parent_name, "SORTING MODE") == 0)
{
/*
fprintf (stdout, "Setting type to CUM_CUR_BUTTON at %d\n ",
current_index);
*/
window_button_struct[current_index].type =
CUM_CUR_BUTTON;
current_index++;
}
else if (strcmp (parent_name, "DISPLAY TYPE") == 0)
{
/*
fprintf (stdout, "Setting type to PERCENT_OTHER_BUTTON at %d\n ",
current_index);
*/
window_button_struct[current_index].type =
PERCENT_OTHER_BUTTON;
current_index++;
}
/*
* Begin stand alone options....
*/
else if (strcmp (parent_name, "OPTIONS") == 0)
{
if (strcmp (list[i].name, "SHOW NFS") == 0)
{
/*
fprintf (stdout, "Setting type to SHOW NFS at %d\n ",
current_index);
*/
window_button_struct[current_index].type =
SHOW_NFS_BUTTON;
current_index++;
}
else if (strcmp (list[i].name, "SHOW TOTAL") == 0)
{
/*
fprintf (stdout, "Setting type to SHOW TOTAL at %d\n ",
current_index);
*/
window_button_struct[current_index].type =
SHOW_TOTAL_BUTTON;
current_index++;
}
}
}
}
}
return (current_index);
}
int
count_dynamic_entries (list, entries)
xs_window_menu_struct *list;
int entries;
{
int result = 0;
int i;
for (i = 0; i < entries; i++)
{
if (list[i].sub_menu != NULL)
{
result += count_dynamic_entries (list[i].sub_menu,
list[i].n_sub_items);
}
else
{
if (list[i].dynamic_data_index != -1)
{
result++;
}
}
}
return (result);
}
Widget *
ps_create_menu_buttons (menulist,
nitems,
screenlist,
screen_num,
optionlist,
option_num, /* This is really bogus since it can
* be nested!!!!! */
button,
server_pointer)
ps_menu_struct *menulist;
int nitems;
multi_screen_window_struct *screenlist;
int screen_num;
xs_window_menu_struct *optionlist;
int option_num;
int button;
struct NetworkXswStruct *server_pointer;
{
int i, j;
int k = 0;
int sort_index = 0;
int temp_k = -1;
int result = 0;
Arg args[32];
int argcount;
XFontStruct *Current_Font;
XmFontList Font_List;
Widget *toggle_widget;
struct ps_button_callback_struct *ps_button_struct;
struct window_button_callback_struct *window_button_struct;
/*
* Create the space for the toggle widgets....
*/
toggle_widget =
(Widget *) malloc (sizeof (Widget) * nitems);
/*
* Create the toggle widgets...
*/
Current_Font = XLoadQueryFont (display, server_pointer -> font_name);
Font_List = XmFontListCreate (Current_Font, XmSTRING_DEFAULT_CHARSET);
server_pointer -> ps_button_change = 1;
/*
fprintf (stdout, "creating option widgets....\n");
*/
/*
* Create the Menu Bar
*/
argcount = 0;
XtSetArg (args[argcount], XmNtopAttachment, XmATTACH_WIDGET);
argcount++;
XtSetArg (args[argcount], XmNtopWidget,
server_pointer -> SEPERATE_WINDOWS_LIST[button].title_label);
argcount++;
XtSetArg (args[argcount], XmNrightAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNrightOffset, 0);
argcount++;
XtSetArg (args[argcount], XmNmarginHeight, 0);
argcount++;
XtSetArg (args[argcount], XmNmarginWidth, 0);
argcount++;
XtSetArg (args[argcount], XmNshadowThickness, 1);
argcount++;
server_pointer -> SEPERATE_WINDOWS_LIST[button].option_menu_bar =
XmCreateMenuBar (
server_pointer -> SEPERATE_WINDOWS_LIST[button].form_w,
"submenu", args, argcount);
/*
* Create the menu widgets.....First one is "ON", the rest are "OFF"
*/
server_pointer -> SEPERATE_WINDOWS_LIST[button].current_screen_mode = 0;
/*
* Count how many dynamic callback entires are present....
* Then make space for them....
*/
result = count_dynamic_entries (optionlist, option_num);
/*
fprintf (stdout, "The number of dynamic entires = %d\n", result);
*/
window_button_struct =
(struct window_button_callback_struct *) calloc (result,
sizeof (struct window_button_callback_struct));
/*
* Initialize call back data structures....
*/
result = fill_in_dynamic_window_button_struct (server_pointer,
button,
window_button_struct,
NULL,
optionlist,
option_num,
0);
/*
fprintf (stdout, "The number of dynamic entires filled = %d\n", result);
*/
/*
* Need an array of widgets that correspond to the VIEW buttons.....
*/
server_pointer -> SEPERATE_WINDOWS_LIST[button].screen_widget_list =
(Widget *) malloc (sizeof (Widget) * result);
create_window_option_menu_bar (
NULL,
server_pointer ->
SEPERATE_WINDOWS_LIST[button].option_menu_bar,
optionlist,
option_num,
result,
window_button_struct,
server_pointer ->
SEPERATE_WINDOWS_LIST[button].screen_widget_list);
/*
fprintf (stdout, "DONE to set up menus....\n");
*/
XtManageChild (server_pointer ->
SEPERATE_WINDOWS_LIST[button].option_menu_bar);
for (i = 0; i < nitems; i++)
{
/*
* Set font, foreground, and background.....
*/
argcount = 0;
XtSetArg (args[argcount], XmNfontList, Font_List);
argcount++;
if (menulist[i].state)
{
XtSetArg (args[argcount], XmNbackground,
colorAuxButtonOnBackground.pixel);
argcount++;
XtSetArg (args[argcount], XmNforeground,
colorAuxButtonOnForeground.pixel);
argcount++;
}
else
{
XtSetArg (args[argcount], XmNbackground,
colorAuxButtonOffBackground.pixel);
argcount++;
XtSetArg (args[argcount], XmNforeground,
colorAuxButtonOffForeground.pixel);
argcount++;
}
/*
* Create the toggle button.....
*/
if (menulist[i].type != SCREEN_SWITCH_BUTTON)
{
XtSetArg (args[argcount], XmNindicatorOn, False);
argcount++;
}
/*
* Set up the position of the widget....
*/
if (menulist[i].offset_side == LEFT_SIDE_OFFSET)
{
XtSetArg (args[argcount], XmNleftAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNleftOffset,
4 + menulist[i].offset * FWIDTH);
}
else
{
XtSetArg (args[argcount], XmNrightAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNrightOffset,
menulist[i].offset * FWIDTH);
}
/*
* All widgets will have top attachment to the label
*/
argcount++;
XtSetArg (args[argcount], XmNtopAttachment, XmATTACH_WIDGET);
argcount++;
XtSetArg (args[argcount], XmNtopWidget,
server_pointer -> SEPERATE_WINDOWS_LIST[button].title_label);
argcount++;
{
/*
* WHATS this difference between the IF and the ELSE logic???????
*/
if (menulist[i].screen_number == 0)
toggle_widget[i] =
XtCreateManagedWidget (menulist[i].name,
xmToggleButtonWidgetClass,
server_pointer -> SEPERATE_WINDOWS_LIST[button].form_w,
args,
argcount);
else
toggle_widget[i] =
XtCreateWidget (menulist[i].name,
xmToggleButtonWidgetClass,
server_pointer -> SEPERATE_WINDOWS_LIST[button].form_w,
args,
argcount);
/*
* Initialize the current sort widget list.....
*/
if ((menulist[i].state) && (menulist[i].type == SORT_BUTTON))
{
server_pointer -> SEPERATE_WINDOWS_LIST[button].view_current_sort_widget[k] = toggle_widget[i];
k++;
}
/*
* Add the callback to this toggle button.....
*/
ps_button_struct = (struct ps_button_callback_struct *) calloc (1,
sizeof (struct ps_button_callback_struct));
/*
* For every new screen, sorting is zero relative.......so adjust for it..
*/
if (menulist[i].screen_number == temp_k)
{
sort_index++;
}
else
{
sort_index = 0;
temp_k = menulist[i].screen_number;
}
ps_button_struct -> sort_mode = sort_index;
ps_button_struct -> server_pointer = server_pointer;
ps_button_struct -> button_num = button;
ps_button_struct -> ps_menu = menulist;
ps_button_struct -> ps_menu_index = i;
XtAddCallback (
toggle_widget[i],
XmNarmCallback,
menulist[i].func,
ps_button_struct);
}
}
return (toggle_widget);
}
void
destroy_callback (my_widget, client_data, cbs)
Widget my_widget;
DestroyCallbackClientData *client_data;
XmAnyCallbackStruct *cbs;
{
int button;
struct NetworkXswStruct *temp_server = NULL;
/*
* This is not really destroying anything.... Depends what XmNdeleteResponse
* is set to when the widget is created.....
*/
temp_server = current_server;
button = client_data -> button;
current_server = (struct NetworkXswStruct *) client_data -> server_pointer;
toggle_button_current_server = temp_server;
set_display_mode (button);
toggle_button_current_server = NULL;
current_server = temp_server;
}
create_widget_title (button)
int button;
{
switch (button)
{
case BUTTON_cpu:
sprintf (widget_title,
"Xsw (%s) : CPU",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:CPU->%s",
current_server -> server_name);
break;
case BUTTON_wait:
sprintf (widget_title,
"Xsw (%s) : Wait",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:Wait->%s",
current_server -> server_name);
break;
case BUTTON_other:
sprintf (widget_title,
"Xsw (%s) : Other",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:Other->%s",
current_server -> server_name);
break;
case BUTTON_mem:
sprintf (widget_title,
"Xsw (%s) : MEM",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:MEM->%s",
current_server -> server_name);
break;
case BUTTON_cache:
sprintf (widget_title,
"Xsw (%s) : Cache",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:Cache->%s",
current_server -> server_name);
break;
case BUTTON_streams:
sprintf (widget_title,
"Xsw (%s) : Streams",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:Streams->%s",
current_server -> server_name);
break;
case BUTTON_nfsstat:
sprintf (widget_title,
"Xsw (%s) : NFS stats",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:NFS stats->%s",
current_server -> server_name);
break;
case BUTTON_sysinfo:
sprintf (widget_title,
"Xsw (%s) : Sysinfo",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:Sysinfo->%s",
current_server -> server_name);
break;
case BUTTON_tune_var:
sprintf (widget_title,
"Xsw (%s) : VBT",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:VBT->%s",
current_server -> server_name);
break;
case BUTTON_dev_stats:
sprintf (widget_title,
"Xsw (%s) : Dev. stats",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:Dev. Stats->%s",
current_server -> server_name);
break;
case BUTTON_disk_space:
sprintf (widget_title,
"Xsw (%s) : Disk Space",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:Disk Space->%s",
current_server -> server_name);
break;
case BUTTON_ps_mem:
sprintf (widget_title,
"Xsw (%s) : PS MEM",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:PS MEM->%s",
current_server -> server_name);
break;
case BUTTON_ps_cpu:
sprintf (widget_title,
"Xsw (%s) : PS CPU",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:PS CPU->%s",
current_server -> server_name);
break;
case BUTTON_ps_io:
sprintf (widget_title,
"Xsw (%s) : PS I/O",
current_server -> server_name);
sprintf (widget_icon_name,
"Xsw:PS I/O->%s",
current_server -> server_name);
break;
}
}
void
get_widget_geometry (button)
int button;
{
XrmDatabase the_database;
char *string_type;
XrmValue string_value;
char *query_string;
char temp;
Position x_position, y_position;
Bool result = 0;
current_server -> SEPERATE_WINDOWS_LIST[button].class_name =
(char *) malloc (strlen (current_server -> server_name) + 20
* (sizeof (char)));
sprintf (current_server -> SEPERATE_WINDOWS_LIST[button].class_name,
"%s%s", Client_decl[button].classname,
current_server -> server_name);
query_string =
(char *) malloc (strlen (current_server -> server_name) + 28
* (sizeof (char)));
sprintf (query_string,
"%s%s",
current_server -> SEPERATE_WINDOWS_LIST[button].class_name,
".geometry");
/*
fprintf(stdout,"query string = %s\n",query_string);
*/
the_database = XrmGetDatabase (display);
string_type = XtMalloc (sizeof (char) * 200);
result = XrmGetResource (the_database,
query_string,
query_string,
&string_type, &string_value);
/*
fprintf(stdout,"result = %d\n",result);
*/
free (query_string);
current_server -> SEPERATE_WINDOWS_LIST[button].GeometryQueryResults = result;
if (result == 1)
{
sscanf (string_value.addr, "%d%c%d%d%d",
¤t_server -> SEPERATE_WINDOWS_LIST[button].width,
&temp,
¤t_server -> SEPERATE_WINDOWS_LIST[button].height,
&x_position, &y_position);
/*
fprintf(stdout,"Xpostion = %d, Ypostion = %d\n",
x_position,y_position);
*/
if (current_server -> SEPERATE_WINDOWS_LIST[button].width >
current_server -> SEPERATE_WINDOWS_LIST[button].max_width)
{
current_server -> SEPERATE_WINDOWS_LIST[button].width =
current_server -> SEPERATE_WINDOWS_LIST[button].max_width;
}
if (current_server -> SEPERATE_WINDOWS_LIST[button].width <
current_server -> SEPERATE_WINDOWS_LIST[button].min_width)
{
current_server -> SEPERATE_WINDOWS_LIST[button].width =
current_server -> SEPERATE_WINDOWS_LIST[button].min_width;
}
if (current_server -> SEPERATE_WINDOWS_LIST[button].height >
current_server -> SEPERATE_WINDOWS_LIST[button].max_height)
{
/*
fprintf(stdout,"hight is to big\n");
*/
current_server -> SEPERATE_WINDOWS_LIST[button].height =
current_server -> SEPERATE_WINDOWS_LIST[button].max_height;
}
if (current_server -> SEPERATE_WINDOWS_LIST[button].height <
current_server -> SEPERATE_WINDOWS_LIST[button].min_height)
{
/*
fprintf(stdout,"hight is to small\n");
*/
current_server -> SEPERATE_WINDOWS_LIST[button].height =
current_server -> SEPERATE_WINDOWS_LIST[button].min_height;
}
}
XtFree (string_type);
}
void
create_shell_widget (button)
int button;
{
Arg args[20];
int argcount;
DestroyCallbackClientData *destroy_client_data;
argcount = 0;
XtSetArg (args[argcount], XmNdeleteResponse, XmUNMAP);
argcount++;
XtSetArg (args[argcount], XmNiconName, widget_icon_name);
argcount++;
XtSetArg (args[argcount], XmNtitle, widget_title);
argcount++;
XtSetArg (args[argcount], XmNallowShellResize, True);
argcount++;
XtSetArg (args[argcount], XmNunitType, XmPIXELS);
argcount++;
XtSetArg (args[argcount], XmNsaveUnder, True);
argcount++;
XtSetArg (args[argcount], XmNmaxHeight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].max_height);
argcount++;
XtSetArg (args[argcount], XmNmaxWidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].max_width);
argcount++;
XtSetArg (args[argcount], XmNminHeight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].min_height);
argcount++;
XtSetArg (args[argcount], XmNminWidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].min_width);
argcount++;
XtSetArg (args[argcount], XmNheight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].height);
argcount++;
XtSetArg (args[argcount], XmNwidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].width);
argcount++;
current_server -> SEPERATE_WINDOWS_LIST[button].shell_widget =
XtCreatePopupShell (
current_server -> SEPERATE_WINDOWS_LIST[button].class_name,
topLevelShellWidgetClass,
toplevel,
args, argcount);
destroy_client_data = (DestroyCallbackClientData *)
malloc (sizeof (DestroyCallbackClientData));
destroy_client_data -> button = button;
destroy_client_data -> server_pointer = (caddr_t) current_server;
current_server ->
SEPERATE_WINDOWS_LIST[button].destroy_client_data_pointer =
destroy_client_data;
current_server -> SEPERATE_WINDOWS_LIST[button].display =
XtDisplay (current_server -> SEPERATE_WINDOWS_LIST[button].shell_widget);
current_server -> SEPERATE_WINDOWS_LIST[button].screen =
DefaultScreen (current_server -> SEPERATE_WINDOWS_LIST[button].display);
/*
* Add a protocol callback for the window manager. I want to know if
* a user/WM closes one of the seperate windows via the window manager!
*/
destroy_client_data -> WM_DELETE_WINDOW =
XmInternAtom (current_server -> SEPERATE_WINDOWS_LIST[button].display,
"WM_DELETE_WINDOW", False);
XmAddWMProtocolCallback (current_server -> SEPERATE_WINDOWS_LIST[button].shell_widget,
destroy_client_data -> WM_DELETE_WINDOW,
destroy_callback,
(caddr_t) destroy_client_data);
}
void
create_paned_widget (button)
int button;
{
Arg args[10];
int argcount;
argcount = 0;
XtSetArg (args[argcount], XmNseparatorOn, False);
argcount++;
XtSetArg (args[argcount], XmNskipAdjust, True);
argcount++;
XtSetArg (args[argcount], XmNallowResize, True);
argcount++;
XtSetArg (args[argcount], XmNmarginHeight, 0);
argcount++;
XtSetArg (args[argcount], XmNmarginWidth, 0);
argcount++;
XtSetArg (args[argcount], XmNheight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].height);
argcount++;
XtSetArg (args[argcount], XmNwidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].width);
argcount++;
current_server -> SEPERATE_WINDOWS_LIST[button].paned_w =
XtCreateManagedWidget ("paned",
xmPanedWindowWidgetClass,
current_server -> SEPERATE_WINDOWS_LIST[button].shell_widget,
args,
argcount);
}
create_main_window_widget (button)
int button;
{
Arg args[10];
int argcount;
XFontStruct *Current_Font;
XmFontList Font_List;
char *label_string = "XSW";
argcount = 0;
if ((button == BUTTON_ps_cpu) ||
(button == BUTTON_ps_io) ||
(button == BUTTON_ps_mem) ||
(button == BUTTON_disk_space))
{
Current_Font = XLoadQueryFont (display, current_server -> font_name);
Font_List = XmFontListCreate (Current_Font, XmSTRING_DEFAULT_CHARSET);
/*
* Create the form for the toggle widgets...
*/
argcount = 0;
XtSetArg (args[argcount], XmNpaneMinimum, (FHEIGHT * 3));
argcount++;
XtSetArg (args[argcount], XmNpaneMaximum, (FHEIGHT * 3));
argcount++;
current_server -> SEPERATE_WINDOWS_LIST[button].form_w =
XtCreateWidget ("paned",
xmFormWidgetClass,
current_server -> SEPERATE_WINDOWS_LIST[button].paned_w,
args,
argcount);
argcount = 0;
XtSetArg (args[argcount], XmNfontList, Font_List);
argcount++;
XtSetArg (args[argcount], XmNtopAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNleftAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNrightAttachment, XmATTACH_FORM);
argcount++;
if (button == BUTTON_ps_cpu)
{
label_string = ps_cpu_screens[0].default_title;
}
else if (button == BUTTON_ps_io)
{
label_string = ps_io_screens[0].default_title;
}
else if (button == BUTTON_ps_mem)
{
label_string = ps_mem_screens[0].default_title;
}
else if (button == BUTTON_disk_space)
{
label_string = disk_space_screens[0].default_title;
}
current_server -> SEPERATE_WINDOWS_LIST[button].title_label =
XtCreateManagedWidget (label_string,
xmLabelWidgetClass,
current_server -> SEPERATE_WINDOWS_LIST[button].form_w,
args,
argcount);
if (button == BUTTON_ps_cpu)
current_server -> SEPERATE_WINDOWS_LIST[button].toggle_widget =
ps_create_menu_buttons (ps_toggle_button_data,
XtNumber (ps_toggle_button_data),
NULL, 0,
ps_cpu_option_menu_bar_data,
XtNumber (ps_cpu_option_menu_bar_data),
button,
current_server);
else if (button == BUTTON_ps_mem)
{
current_server -> SEPERATE_WINDOWS_LIST[button].toggle_widget
= ps_create_menu_buttons (ps_mem_toggle_button_data,
XtNumber (ps_mem_toggle_button_data),
ps_mem_screens,
XtNumber (ps_mem_screens),
ps_mem_option_menu_bar_data,
XtNumber (ps_mem_option_menu_bar_data),
button,
current_server);
}
else if (button == BUTTON_ps_io)
{
current_server ->
SEPERATE_WINDOWS_LIST[button].toggle_widget =
ps_create_menu_buttons (ps_io_toggle_button_data,
XtNumber (ps_io_toggle_button_data),
NULL, 0,
ps_io_option_menu_bar_data,
XtNumber (ps_io_option_menu_bar_data),
button,
current_server);
}
else if (button == BUTTON_disk_space)
current_server ->
SEPERATE_WINDOWS_LIST[button].toggle_widget =
ps_create_menu_buttons (disk_space_toggle_button_data,
XtNumber (disk_space_toggle_button_data),
disk_space_screens,
XtNumber (disk_space_screens),
option_menu_bar_data,
XtNumber (option_menu_bar_data),
button,
current_server);
XtManageChild (current_server -> SEPERATE_WINDOWS_LIST[button].form_w);
argcount = 0;
XtSetArg (args[argcount], XmNscrollingPolicy, XmAUTOMATIC);
argcount++;
XtSetArg (args[argcount], XmNincrement, FWIDTH);
argcount++;
}
XtSetArg (args[argcount], XmNheight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].height);
argcount++;
XtSetArg (args[argcount], XmNwidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].width);
argcount++;
current_server -> SEPERATE_WINDOWS_LIST[button].main_window_widget =
XmCreateMainWindow (
current_server -> SEPERATE_WINDOWS_LIST[button].paned_w,
"mainWindow",
args,
argcount);
}
void
set_up_shell_max_sizes (button)
int button;
{
Arg args[10];
int argcount;
argcount = 0;
XtSetArg (args[argcount], XmNmaxHeight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].max_height);
argcount++;
XtSetArg (args[argcount], XmNmaxWidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].max_width);
argcount++;
XtSetArg (args[argcount], XmNminHeight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].min_height);
argcount++;
XtSetArg (args[argcount], XmNminWidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].min_width);
argcount++;
XtSetValues (
current_server -> SEPERATE_WINDOWS_LIST[button].shell_widget,
args, argcount);
}
void
set_up_shell_size (button)
int button;
{
Arg args[10];
int argcount;
argcount = 0;
/*
XtSetArg (args[argcount], XmNmaxHeight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].max_height);
argcount++;
XtSetArg (args[argcount], XmNmaxWidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].max_width);
argcount++;
XtSetArg (args[argcount], XmNminHeight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].min_height);
argcount++;
XtSetArg (args[argcount], XmNminWidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].min_width);
argcount++;
*/
/*
* Should not have to set these! The window manager positions the window
* for us.
XtSetArg (args[argcount], XmNx,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].x1);
argcount++;
XtSetArg (args[argcount], XmNy,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].y1);
argcount++;
*/
XtSetArg (args[argcount], XmNheight,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].height);
argcount++;
XtSetArg (args[argcount], XmNwidth,
(XtArgVal) current_server ->
SEPERATE_WINDOWS_LIST[button].width);
argcount++;
XtSetValues (
current_server -> SEPERATE_WINDOWS_LIST[button].shell_widget,
args, argcount);
}
void
create_drawing_area (button)
int button;
{
Arg args[32];
int argcount;
struct expose_callback_struct *expose_data;
struct scrolled_ps_callback_struct *scrolled_ps_callback;
/*
* Create the drawing area and manage it...
*/
argcount = 0;
XtSetArg (args[argcount], XmNallowShellResize, True);
argcount++;
XtSetArg (args[argcount], XmNforeground, foreground);
argcount++;
XtSetArg (args[argcount], XmNbackground, background);
argcount++;
XtSetArg (args[argcount], XmNunitType, XmPIXELS);
argcount++;
XtSetArg (args[argcount], XmNwidth,
current_server -> SEPERATE_WINDOWS_LIST[button].draw_width);
argcount++;
XtSetArg (args[argcount], XmNheight,
current_server -> SEPERATE_WINDOWS_LIST[button].draw_height);
argcount++;
current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW =
XmCreateDrawingArea (
current_server -> SEPERATE_WINDOWS_LIST[button].main_window_widget,
"xsw-draw", args, argcount);
XtManageChild (current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW);
/*
* Lets create a Pixmap the same size of the drawing area.........
*/
current_server -> SEPERATE_WINDOWS_LIST[button].pixmap =
XCreatePixmap (
XtDisplay (current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW),
RootWindowOfScreen (
XtScreen (current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW)),
current_server -> SEPERATE_WINDOWS_LIST[button].draw_width,
current_server -> SEPERATE_WINDOWS_LIST[button].draw_height,
DefaultDepthOfScreen (
XtScreen (current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW)));
/*
* Set main window areas....
*/
XmMainWindowSetAreas (
current_server -> SEPERATE_WINDOWS_LIST[button].main_window_widget,
NULL,
NULL,
NULL,
NULL,
current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW);
/*
* Now manage the main window
*/
XtManageChild (
current_server -> SEPERATE_WINDOWS_LIST[button].main_window_widget);
if ((button == BUTTON_ps_cpu) ||
(button == BUTTON_ps_io) ||
(button == BUTTON_ps_mem) ||
(button == BUTTON_disk_space))
{
argcount = 0;
XtSetArg (args[argcount], XmNhorizontalScrollBar,
¤t_server -> SEPERATE_WINDOWS_LIST[button].hsb);
argcount++;
XtGetValues (
current_server -> SEPERATE_WINDOWS_LIST[button].main_window_widget,
args,
argcount);
argcount = 0;
XtSetArg (args[argcount], XmNrepeatDelay,
0);
argcount++;
XtSetValues (
current_server -> SEPERATE_WINDOWS_LIST[button].main_window_widget,
args,
argcount);
scrolled_ps_callback =
(struct scrolled_ps_callback_struct *)
calloc (1,
sizeof (struct scrolled_ps_callback_struct));
scrolled_ps_callback -> server_pointer = current_server;
scrolled_ps_callback -> button_number = button;
if (button == BUTTON_ps_cpu)
{
scrolled_ps_callback -> ps_menu = ps_toggle_button_data;
scrolled_ps_callback -> number_of_buttons = XtNumber (ps_toggle_button_data);
scrolled_ps_callback -> number_of_screens = XtNumber (ps_cpu_screens);
}
if (button == BUTTON_ps_mem)
{
scrolled_ps_callback -> ps_menu = ps_mem_toggle_button_data;
scrolled_ps_callback -> number_of_buttons = XtNumber (ps_mem_toggle_button_data);
scrolled_ps_callback -> number_of_screens = XtNumber (ps_mem_screens);
}
if (button == BUTTON_ps_io)
{
scrolled_ps_callback -> ps_menu = ps_io_toggle_button_data;
scrolled_ps_callback -> number_of_buttons = XtNumber (ps_io_toggle_button_data);
scrolled_ps_callback -> number_of_screens = XtNumber (ps_io_screens);
}
if (button == BUTTON_disk_space)
{
scrolled_ps_callback -> ps_menu = disk_space_toggle_button_data;
scrolled_ps_callback -> number_of_buttons = XtNumber (disk_space_toggle_button_data);
scrolled_ps_callback -> number_of_screens = XtNumber (disk_space_screens);
}
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].hsb,
XmNvalueChangedCallback,
scrolled_ps,
scrolled_ps_callback);
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].hsb,
XmNdragCallback,
scrolled_ps,
scrolled_ps_callback);
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].hsb,
XmNincrementCallback,
scrolled_ps,
scrolled_ps_callback);
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].hsb,
XmNdecrementCallback,
scrolled_ps,
scrolled_ps_callback);
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].hsb,
XmNpageDecrementCallback,
scrolled_ps,
scrolled_ps_callback);
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].hsb,
XmNpageIncrementCallback,
scrolled_ps,
scrolled_ps_callback);
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].hsb,
XmNtoTopCallback,
scrolled_ps,
scrolled_ps_callback);
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].hsb,
XmNtoBottomCallback,
scrolled_ps,
scrolled_ps_callback);
}
/*
* Add callbacks.....
*/
expose_data = (struct expose_callback_struct *)
calloc (1, sizeof (struct expose_callback_struct));
expose_data -> server_pointer = current_server;
expose_data -> button_number = button;
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW,
XmNresizeCallback, expose_callback,
expose_data);
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW,
XmNexposeCallback, expose_callback,
expose_data);
XtAddCallback (current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW,
XmNinputCallback, input_callback,
current_server);
/*
* Pop up the window...
*/
XtPopup (
current_server -> SEPERATE_WINDOWS_LIST[button].shell_widget, XtGrabNone);
/*
* Get the window ID, and Graphic Context
*/
current_server -> SEPERATE_WINDOWS_LIST[button].window =
XtWindow (current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW);
current_server -> SEPERATE_WINDOWS_LIST[button].gc =
XCreateGC (current_server -> SEPERATE_WINDOWS_LIST[button].display,
current_server -> SEPERATE_WINDOWS_LIST[button].window,
0,
NULL);
/*
* Initialize pixmap....
*/
XSetForeground (
current_server -> SEPERATE_WINDOWS_LIST[button].display,
current_server -> SEPERATE_WINDOWS_LIST[button].gc,
background);
XFillRectangle (
current_server -> SEPERATE_WINDOWS_LIST[button].display,
current_server -> SEPERATE_WINDOWS_LIST[button].pixmap,
current_server -> SEPERATE_WINDOWS_LIST[button].gc,
0,
0,
DisplayWidth (display, screen),
DisplayHeight (display, screen));
/*
* Set the user data of the drawing area to the graphic context...
*/
argcount = 0;
XtSetArg (args[argcount], XmNuserData, current_server ->
SEPERATE_WINDOWS_LIST[button].gc);
argcount++;
XtSetValues (current_server -> SEPERATE_WINDOWS_LIST[button].DrawAreaW,
args, argcount);
/*
* Set Foreground, Background, and Font for this server....
*/
XSetForeground (current_server -> SEPERATE_WINDOWS_LIST[button].display,
current_server -> SEPERATE_WINDOWS_LIST[button].gc,
foreground);
XSetBackground (current_server -> SEPERATE_WINDOWS_LIST[button].display,
current_server -> SEPERATE_WINDOWS_LIST[button].gc,
background);
XSetFont (current_server -> SEPERATE_WINDOWS_LIST[button].display,
current_server -> SEPERATE_WINDOWS_LIST[button].gc,
current_server -> My_font);
}
void
create_seperate_windows_widgets (button)
int button;
{
void draw_display (int, Window);
struct ps_button_callback_struct *scrolled_ps_callback;
XDefineCursor (display, XtWindow (toplevel), res.wait_cursor);
create_widget_title (button);
get_widget_geometry (button);
create_shell_widget (button);
create_paned_widget (button);
create_main_window_widget (button);
/*
create_drawing_area does the following:
1) Create drawing area
2) Create pixmap
3) Set main window area
4) Set up scroll bars for those windows that need it.
5) Add expose call backs
6) Pop up window
7) Initialize window context variables
8) Initialize pixmap
9) Initialize drawing area context
10) Set foreground, background, and font for current window.
*/
create_drawing_area (button);
set_up_shell_size (button);
XDefineCursor (display, XtWindow (toplevel), res.cursor);
current_server -> SEPERATE_WINDOWS_LIST[button].first_expose = 1;
if (button == BUTTON_ps_mem)
{
read_memory_stats (current_server);
}
current_server -> SEPERATE_WINDOWS_LIST[button].already_created = 1;
current_server -> SEPERATE_WINDOWS_LIST[button].help_color_already_created = 0
;
draw_display (1, current_server -> SEPERATE_WINDOWS_LIST[button].window);
update_display (1, current_server -> SEPERATE_WINDOWS_LIST[button].window);
XtResizeWindow (current_server -> SEPERATE_WINDOWS_LIST[button].shell_widget);
}
/* end of sepwin.c */